﻿<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>弹出框</title>
    <meta charset="utf-8" />

</head>
<body id="body">
    <form id="form1" name="form1">
        <input type="text" id="showModalInput" name="showModalInput" />
        <input type="button" id="showModalButton" value="选择" />
    </form>
    <!--JS-->
    <script src="http://libs.baidu.com/jquery/1.8.3/jquery.min.js"></script>
    <script>
        var $button = $("#showModalButton");
        $button.on("click", function () {
            openwin("select/SelectUser.html", 652, 575);
        });

        //chromv37中不支持showModalDialog方面，自己使用window.open模拟出来
        window.showModalDialog = function (url, arg, feature) {
            var
                    opFeature = feature.split(";"),
                    featuresArray = new Array();

            if (document.all) {
                for (var i = 0; i < opFeature.length - 1; i++) {
                    var f = opFeature[i].split("=");
                    featuresArray[f[0]] = f[1];
                }
            }
            else {
                for (var i = 0; i < opFeature.length - 1; i++) {
                    var f = opFeature[i].split(":");
                    featuresArray[f[0].toString().trim().toLowerCase()] = f[1].toString().trim();
                }
            }

            var
                    h = "200px",
                    w = "400px",
                    l = "100px",
                    t = "100px",
                    r = "yes",
                    c = "yes",
                    s = "no";

            if (featuresArray["dialogheight"]) h = featuresArray["dialogheight"];
            if (featuresArray["dialogwidth"]) w = featuresArray["dialogwidth"];
            if (featuresArray["dialogleft"]) l = featuresArray["dialogleft"];
            if (featuresArray["dialogtop"]) t = featuresArray["dialogtop"];
            if (featuresArray["resizable"]) r = featuresArray["resizable"];
            if (featuresArray["center"]) c = featuresArray["center"];
            if (featuresArray["status"]) s = featuresArray["status"];
            var modelFeature = "height = " + h + ",width = " + w + ",left=" + l + ",top=" + t + ",model=yes,alwaysRaised=yes" + ",resizable= " + r + ",celter=" + c + ",status=" + s;

            var model = window.open(url, "", modelFeature, null);

            model.dialogArguments = arg;

            if (model.dialogArguments.callback) {
                model.dialogArguments.callback.call(window);
            }

        }


        //封装弹出窗口方法
        function openwin(url, width, height) {
            var
                s_wid = document.documentElement.clientWidth,
                s_hei = document.documentElement.clientHeight,
                l_wid = (s_wid - width) / 2;
            var showWin = window.showModalDialog("select/SelectUser.html", window, "dialogTop:30px;dialogLeft:" + l_wid + "px; dialogWidth:" + width + "px;dialogHeight:" + height + "px;center:no;status:no;scroll:no;help:no;resizable:no;edge:sunken");
        }
    </script>
</body>
</html>
